package com.czy.owner.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.TextView;

import com.czy.owner.R;
import com.czy.owner.entity.GrowthValueDetailsList;
import com.czy.owner.utils.PhoneUtils;
import com.czy.owner.utils.TimeUtils;
import com.easyrecycleview.adapter.BaseViewHolder;
import com.easyrecycleview.adapter.RecyclerArrayAdapter;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by wangyang on 2017/5/18 0018.
 */

public class GrowthValueListAdapter extends RecyclerArrayAdapter<GrowthValueDetailsList> {

    private Context context;


    public GrowthValueListAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        return new GrowthValueListHolder(parent);
    }

    class GrowthValueListHolder extends BaseViewHolder<GrowthValueDetailsList> {


        @BindView(R.id.tv_type)
        TextView tvType;
        @BindView(R.id.tv_time)
        TextView tvTime;
        @BindView(R.id.tv_num)
        TextView tvNum;

        public GrowthValueListHolder(ViewGroup parent) {
            super(parent, R.layout.item_growth_value_list);
            ButterKnife.bind(this, itemView);
        }

        @Override
        public void setData(final GrowthValueDetailsList data) {
            super.setData(data);

            switch (data.getGrowthValueType()) {
                case "register":
                    tvType.setText("注册");
                    break;
                case "comment":
                    tvType.setText("评论");
                    break;
                case "sign":
                    tvType.setText("签到");
                    break;
                case "share":
                    tvType.setText("商品分享");
                    break;
                case "consumption":
                    tvType.setText("消费");
                    break;
                case "addCar":
                    tvType.setText("添加车辆");
                    break;
                case "refund":
                    tvType.setText("退款");
                    break;
                default:
                    tvType.setText("");

                    break;

            }
            tvTime.setText(TimeUtils.formatTimeDifference3(data.getcTime()));
            if (data.getGrowthValueAdd().contains("-")) {
                tvNum.setText(data.getGrowthValueAdd());
            } else {
                tvNum.setText("+" + data.getGrowthValueAdd());

            }
        }
    }

}